﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using VOL.Domain.Dto;
using VOL.Domain.IServices.EquipmentManagement;
using VOL.Entity.DomainModels;

namespace VOL.WebApi.Controllers.EquipmentManagement
{
    /// <summary>
    /// 点检记录
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RecordsInspectionsController : ControllerBase
    {
        private IRecordsInspectionsService _recordsInspectionsService;

        public RecordsInspectionsController(IRecordsInspectionsService recordsInspectionsService)
        {
            _recordsInspectionsService= recordsInspectionsService;
        }

        /// <summary>
        /// 点检记录的添加
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddRecordsinspections([FromBody] RecordsInspections recordsInspections)
        {
            var result = await _recordsInspectionsService.AddRecordsinspections(recordsInspections);
            return result;
        }

        /// <summary>
        /// 点检记录的显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<RecordsInspections>> GetRecordsinspectionsList(GetRecordsinspectionsListDTO request)
        {
            return await _recordsInspectionsService.GetRecordsinspectionsList(request);
        }

        /// <summary>
        /// 点检记录的删除
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<int> DeleteRecordsinspections(int id)
        {
            return await _recordsInspectionsService.DeleteRecordsinspections(id);
        }

        /// <summary>
        /// 点检记录的修改
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateRecordsinspections([FromBody]RecordsInspections recordsInspections)
        {
            return await _recordsInspectionsService.UpdateRecordsinspections(recordsInspections);
        }
    }
}
